pip install plotly
Note: you may need to restart the kernel to use updated packages.
'C:\Users\Ankit' is not recognized as an internal or external command, operable program or batch file.
import plotly.express as px
fig=px.line(x=[1,2,3],y=[1,2,3])
print(fig)
Figure({
'data': [{'hovertemplate': 'x=%{x}<br>y=%{y}<extra></extra>',
'legendgroup': '',
'line': {'color': '#636efa', 'dash': 'solid'},
'marker': {'symbol': 'circle'},
'mode': 'lines',
'name': '',
'orientation': 'v',
'showlegend': False,
'type': 'scatter',
'x': array([1, 2, 3], dtype=int64),
'xaxis': 'x',
'y': array([1, 2, 3], dtype=int64),
'yaxis': 'y'}],
'layout': {'legend': {'tracegroupgap': 0},
'margin': {'t': 60},
'template': '...',
'xaxis': {'anchor': 'y', 'domain': [0.0, 1.0], 'title': {'text': 'x'}},
'yaxis': {'anchor': 'x', 'domain': [0.0, 1.0], 'title': {'text': 'y'}}}
})
import plotly.express as px
fig=px.line(x=[1,2,3],y=[1,2,3])
fig.show()
import plotly. express as px
df=px.data.iris()
fig=px.line(df,x="species",y="petal_width")
fig.show()
import plotly.express as px
df=px.data.iris()
fig=px.bar(df,x="sepal_width",y="sepal_length")
fig.show()
import plotly.express as px
import numpy as np
np.random.seed(42)
random_x=np.random.randint(1,101,100)
random_y=np.random.randint(1,101,100)
fig=px.bar(random_x,y=random_y)
fig.show()
import plotly.express as px
df=px.data.iris()
fig=px.bar(df,x="sepal_width",y="sepal_length")
fig.show()
long_df=px.data.medals_long()
fig=px.bar(long_df,x="nation",y="count",
color="medal",title="nation")
fig.show()
df=px.data.medals_wide()
fig=px.bar(df,x="nation",
y=["gold","silver","bronze"],
title="Wide form data")
fig.show()
import plotly.express as px
df=px.data.iris()
fig=px.bar(df,x="sepal_width",y="sepal_length",
color="species",barmode="group",
facet_row="species",facet_col="species")
fig.show()
#customizing bar charts
import plotly.express as px
df=px.data.iris()
fig=px.bar(df,x="sepal_width",y="sepal_length",color="species")
fig.show()
import plotly.express as px
df=px.data.iris()
fig=px.bar(df,x="sepal_width",y="sepal_length",
color="species",barmode="overlay")
fig.show()
#using tips dataset
import plotly.express as px
df=px.data.tips()
fig=px.histogram(df,x="total_bill")
fig.show()
import plotly.express as px
df=px.data.tips()
fig=px.histogram(df,x="total_bill",
histnorm="probability density")
fig.show()
df=px.data.tips()
fig=px.histogram(df,x="total_bill",histnorm="percent")
fig.show()
df=px.data.tips()
fig=px.histogram(df,x="total_bill",
histnorm="percent",
nbins=10)
fig.show()